﻿//===============================================================================
// Apolineo Patterns & Practices LeanEngine Framework
//===============================================================================
// Copyright © Apolineo Desenvolvimento de Sistemas Ltda.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using LeanEngine.Business.Security.Entity;

namespace LeanEngine.SalesConcept.Windows
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            using (var formLogin = new FormLogin())
            {
                formLogin.LoginSuccess += new Action<FormLogin>(formLogin_LoginSuccess);

                if (formLogin.ShowDialog() == DialogResult.OK)
                {
                    Application.Run(new FormMain());
                }
            }
        }

        static void formLogin_LoginSuccess(FormLogin form)
        {
            LoginToken = form.SecureToken;
            form.DialogResult = DialogResult.OK;

            form.Close();
        }

        internal static Token LoginToken { get; set; }
    }
}
